home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / CBASE102.ARJ / CBRECPRE.C < prev    next >
Text File  |  1991-09-23  |  2KB  |  79 lines

  1. /*    Copyright (c) 1989 Citadel    */
  2. /*       All Rights Reserved        */
  3.  
  4. /* #ident    "@(#)cbrecpre.c    1.5 - 91/09/23" */
  5.  
  6. #include <ansi.h>
  7.  
  8. /* ansi headers */
  9. #include <errno.h>
  10.  
  11. /* library headers */
  12. #include <lseq.h>
  13.  
  14. /* local headers */
  15. #include "cbase_.h"
  16.  
  17. /*man---------------------------------------------------------------------------
  18. NAME
  19.      cbrecprev - previous cbase record
  20.  
  21. SYNOPSIS
  22.      #include <cbase.h>
  23.  
  24.      int cbrecprev(cbp)
  25.      cbase_t *cbp;
  26.  
  27. DESCRIPTION
  28.      The cbrecprev function retreats the record cursor of cbase cbp to
  29.      the previous record.  If the cursor is on the first record, it is
  30.      retreated to null.
  31.  
  32.      cbrecprev will fail if one or more of the following is true:
  33.  
  34.      [EINVAL]       cbp is not a valid cbase pointer.
  35.      [CBELOCK]      cbp is not locked.
  36.      [CBENOPEN]     cbp is not open.
  37.  
  38. SEE ALSO
  39.      cbrcursor, cbrecfirst, cbreclast, cbrecnext.
  40.  
  41. DIAGNOSTICS
  42.      Upon successful completion, a value of 0 is returned.  Otherwise,
  43.      a value of -1 is returned, and errno set to indicate the error.
  44.  
  45. ------------------------------------------------------------------------------*/
  46. #ifdef AC_PROTO
  47. int cbrecprev(cbase_t *cbp)
  48. #else
  49. int cbrecprev(cbp)
  50. cbase_t *cbp;
  51. #endif
  52. {
  53.     /* validate arguments */
  54.     if (!cb_valid(cbp)) {
  55.         errno = EINVAL;
  56.         return -1;
  57.     }
  58.  
  59.     /* check if not open */
  60.     if (!(cbp->flags & CBOPEN)) {
  61.         errno = CBENOPEN;
  62.         return -1;
  63.     }
  64.  
  65.     /* check if not locked */
  66.     if (!(cbp->flags & CBLOCKS)) {
  67.         errno = CBELOCK;
  68.         return -1;
  69.     }
  70.  
  71.     /* retreat cursor to previous record */
  72.     if (lsprev(cbp->lsp) == -1) {
  73.         CBEPRINT;
  74.         return -1;
  75.     }
  76.  
  77.     return 0;
  78. }
  79.